#include "CT_Vertex_Info.h"
#include "Log.h"

CT_Vertex_Info::CT_Vertex_Info(int ID, double distance) {
    LOG_ENTER(GRAPH, "CT_Vertex_Info::CT_Vertex_Info");

    this->cluster_ID = ID;
    this->leaf_distance = distance;

    LOG_EXIT();
}

std::ostream& CT_Vertex_Info::print(std::ostream& os) const {
    os << "[ " << cluster_ID << " " << leaf_distance << " ]";
        return os;
}

bool CT_Vertex_Info::match(Parser& parser) {
    LOG_ENTER(INPUT, "CT_Vertex_Info::match");

    int m = 0;
    m += parser.match_char  ("[");
    m += parser.match_int   (cluster_ID);
    m += parser.match_double(leaf_distance);
    m += parser.match_char  ("]");

    if (m == 4) {

        LOG_EXIT();

        return true;
    }

    parser.backup(m);

    LOG_EXIT();

    return false;
}

std::ostream& operator<<( std::ostream& os,
                          const CT_Vertex_Info& v ) {
    return v.print(os);
}

